import 'package:get/get.dart';

import 'bar_chart1_state.dart';

class BarChart1Logic extends GetxController {
  final BarChart1State state = BarChart1State();

  /// 播放事件
  void play() async{
    state.isPlaying = !state.isPlaying;
    if (state.isPlaying) {
      refreshState();
    }
    update();
  }

  /// 刷新状态
  Future<dynamic> refreshState() async {
    update();
    await Future<dynamic>.delayed(
      state.animDuration + const Duration(milliseconds: 50),
    );
    if (state.isPlaying) {
      await refreshState();
    }
  }
}
